package goleetcode

import (
	"sort"
	"strconv"
	"strings"
)

func splitNum(num int) int {
	nums := strconv.Itoa(num)
	numsSlice := strings.Split(nums, "")
	sort.Strings(numsSlice)
	num1, num2 := 0, 0
	for i := 0; i < len(numsSlice); i++ {
		digit, _ := strconv.Atoi(numsSlice[i])
		if i % 2 == 0 {
			num1 = num1 * 10 + (digit)
		} else {
			num2 = num2 * 10 + (digit)
		}
	}
	return num1 + num2
}